<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layui-form layuimini-form layui-form-pane">
    <div class="layui-form-item">
        <input type="hidden" name="code" value="{$info.code}">
        <label class="layui-form-label required">玩家名称</label>
        <div class="layui-input-inline">
            <input type="text" readonly value="{$info.name}" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">玩家ID</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.code}" readonly autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">玩家手机号</label>
        <div class="layui-input-inline">
            <input type="number" readonly value="{$info.phone}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付宝</label>
        <div class="layui-input-inline">
            <input type="text" readonly value="{$info.ali_number}" class="layui-input">
        </div>
        <label class="layui-form-label">微信</label>
        <div class="layui-input-inline">
            <input type="text" readonly value="{$info.wx_number}" class="layui-input">
        </div>
        <label class="layui-form-label">银联</label>
        <div class="layui-input-inline">
            <input type="text" readonly value="{$info.unionpay_number}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">创建行业</label>
        <div class="layui-input-inline">
            <input type="hidden" name="industry_id" id="industryIdHidden" value="{$industry_id}">
            <input type="text"  autocomplete="off" readonly class="layui-input" value="{$industry_title}">
        </div>
        <label class="layui-form-label">输入行业金额</label>
        <div class="layui-input-inline">
            <input type="number" name="earnings_price" min="{$min_worth}" max="{$max_worth}"  placeholder="请输入行业金额" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">选择投放团队</label>
        <div class="layui-input-inline">
            <input type="hidden" name="team_id" id="teamIdHidden">
            <input type="text" placeholder="选择投放团队" autocomplete="off" readonly class="layui-input" id="team">
        </div>
    </div>
    <div class="layui-form-item">
         <label class="layui-form-label required">剩余栏位数</label>
        <div class="layui-input-inline">
            <input type="number" name="plurs_grid" placeholder="可匹配剩余栏位数" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">是否优先</label>
        <div class="layui-input-inline" style="border:solid 1px #e2e2e2">
            <input type="radio" name="precedence" value="1" title="是" checked="">
            <input type="radio" name="precedence" value="2" title="否">
        </div>
    </div>

   
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-radius" lay-submit lay-filter="saveBtn">保存并参与匹配</button>
        </div>
    </div>
</div>
<script type="text/html" id="categoryTpl">
    {{#  if(d.category === 1){ }}
    <span > 普通行业</span>
    {{# }else if(d.category === 2){ }}
    <span style="color: #f59b28;">体验行业</span>
    {{#  } else { }}
    <span style="color: #f42540;">集成行业</span>
    {{#  } }}
</script>
{include file="public/footer" /}
<script>
    layui.use(['form', 'laydate', 'tableSelect', 'layarea', 'upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            tableSelect = layui.tableSelect,
            $ = layui.$;
        /*创建行业*/
        tableSelect.render({
            elem: '#industry',
            searchKey: 'title',
            checkedKey: 'id',
            searchPlaceholder: '名称搜索',
            table: {
                url: '/admin/Industry/Index?action=ajax',
                method: 'post',
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": res.data, //解析数据列表
                    };
                },
                cols: [[
                    {type: 'radio'},
                    {field: 'title', title: '名称'},
                    {field: 'category', title: '类型' ,templet:"#categoryTpl"},
                    {field: 'level', title: '所属等级', sort: true},
                    {field: 'min_worth', title: '基础价值'},
                    {field: 'max_worth', title: '最高价值'},
                ]],
                page: true,
                limits: [10, 15, 20, 25, 30, 50, 100],
                limit: 10
            },
            done: function (elem, data) {
                var NEWJSON = [];
                var industryIdHidden = [];
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.title);
                    $('#industryIdHidden').val(item.id)
                })
                elem.val(NEWJSON.join(","))
            }
        });
        /*选择投放团队*/
        tableSelect.render({
            elem: '#team',
            searchKey: 'title',
            checkedKey: 'id',
            searchPlaceholder: '名称搜索',
            table: {
                url: '/admin/Member/teamInfo?action=ajax',
                method: 'post',
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.data, //解析数据列表
                    };
                },
                cols: [[
                    {type: 'checkbox'},
                    {field: 'title', title: '团队名称', sort: true},
                    {field: 'team_num', title: '团队人数', sort: true},
                    {field: 'income', title: '团队总收益', sort: true},
                ]],
                page: true,
                limits: [10, 15, 20, 25, 30, 50, 100],
                limit: 10
            },
            done: function (elem, data) {
                var NEWJSON = [];
                var teamHidden = [];
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.title)
                    teamHidden.push(item.id)
                })
                elem.val(NEWJSON.join(","))
                $('#teamIdHidden').val(teamHidden.join(","))
            }
        });
        //监听提交
        var min="{$min_worth}"
            max="{$max_worth}";
        form.on('submit(saveBtn)', function (data) {
            if(data.field.earnings_price<parseFloat(min)||data.field.earnings_price>parseFloat(max)){
                layer.msg("请输入有效的价值区间");
                return false;
            }
            $.ajax({
                url: '/admin/TransactionData/launchIndustry?action=ajax',
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (res) {
                    if (res.status == true) {
                        // 关闭弹出层
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });
            return false;
        });

    });
</script>
</body>
</html>